package com.ioudi.digu.dao.support;

import java.util.Date;

import org.hibernate.Query;

public class ReceivedQuerySupport extends AbstractQuerySupport
{
	protected void createQueryItem(Query query, String key, int index, Object value)
	{
		if(key.equals("timestamp"))
		{
			query.setTimestamp(index, (Date)value);
		}
		else if(key.equals("location"))
		{
			query.setEntity(index, value);
		}
		else if(key.equals("isReply"))
		{
			
		}
		else
		{
			query.setString(index, String.valueOf(value));
		}
	}
	
	protected String getStatementItemField(String key)
	{
		if(key.equals("user"))
		{
			return "user";
		}
		else if(key.equals("sender"))
		{
			return "message.account";
		}
		else if(key.equals("isReply"))
		{
			return "message.replyID";
		}
		return "message." + key;
	}
	
	protected String getStatementItemOperator(String key, Object value)
	{
		if(key.equals("timestamp"))
		{
			return ">=";
		}
		return "=";
	}
}
